const baseURL = 'http://192.168.1.6:8888'

// export async function baseFun(url: string, init: RequestInit = {}): Promise<Response> {
//   return await (await fetch(baseURL + url, init)).json()
// }

import axios from 'axios'

export const instance = axios.create({
  baseURL,
  timeout: 5000,
  headers: {
    'Content-Type': 'application/json; charset=utf-8'
  }
})

// 添加请求拦截器
instance.interceptors.request.use(
  (config) => {
    return config
  },
  (error) => {
    return Promise.reject(error)
  }
)

// 添加响应拦截器
instance.interceptors.response.use(
  (response) => {
    console.log('response', response)
    return response.data
  },
  (error) => {
    return Promise.reject(error)
  }
)
